package com.heima.admin.controller;


import com.heima.admin.service.SensitiveManagementService;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmSensitiveDto;
import com.heima.model.wemedia.pojos.WmSensitive;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@Api("敏感词管理")
@RequiredArgsConstructor
@RequestMapping("admin/api/v1/sensitive")
public class SensitiveManagementController {

    private final SensitiveManagementService sensitiveManagementService;


    /**
     * 查询列表
     *
     * @param sensitiveDto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult<List<WmSensitive>> list(@RequestBody WmSensitiveDto sensitiveDto) {

        ResponseResult result = sensitiveManagementService.select(sensitiveDto);

        return result;
    }

    /**
     * 保存
     *
     * @param wmSensitive
     * @return
     */
    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmSensitive wmSensitive) {
        sensitiveManagementService.sensitiveWord(wmSensitive);
        return ResponseResult.okResult(null);
    }


    /**
     * 修改
     *
     * @param wmSensitive
     * @return
     */
    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmSensitive wmSensitive) {

        sensitiveManagementService.updateSensitive(wmSensitive);
        return ResponseResult.okResult(null);

    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @DeleteMapping("/del/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        sensitiveManagementService.delete(id);
        return ResponseResult.okResult(null);
    }

}
